<template>
  <div id="second">
    <div class="pd_20 bg_white el_t_20">
      <el-row :gutter="20">
        <el-col :span="10" class="el-name">预约时间：</el-col>
        <el-col :span="5" class="el-name">预约医生：</el-col>
        <el-col :span="6" class="el-name">个人信息：</el-col>
      </el-row>
      <el-row :gutter="20" class="el_t_10">
        <el-col :span="10">
          <el-date-picker
            size="mini"
            class="el_long"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-col>
        <el-col :span="5">
          <el-select size="mini" v-model="search.name" class="el_long">
            <template v-for="(item,index) in users">
              <el-option :label="item.label" :value="item.key" :key="item.key"></el-option>
            </template>
          </el-select>
        </el-col>
        <el-col :span="6">
          <el-input size="mini" type="text" placeholder="输入姓名/电话等关键字搜索"></el-input>
        </el-col>
        <el-col :span="2" class="text-right">
          <el-button size="mini" type="primary" plain>搜索</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="content">
      <div class="box">
        <el-row :gutter="20" v-if="list.length > 0">
          <template v-for="(item,index) in list">
            <el-col :span="8">
              <div class="item">
                <div class="case">
                  <span
                    class="tag"
                    :class="{warning:index===0,disabled:index===3}"
                  >{{index===0?'失约':index===3?'已取消':'待登记'}}</span>
                  <div class="photo">
                    <img src="./img/photo.png" alt>
                  </div>
                  <div class="text">
                    <p>
                      <span v-html="item.name"></span>
                      {{item.sex}}
                    </p>
                    <p>创建时间：{{item.time}}</p>
                    <p>预约科室：{{item.phone}}</p>
                    <p>预约时间：{{item.time}}</p>
                    <p>
                      出诊：
                      <em v-html="item.remark"></em>
                    </p>
                  </div>
                </div>
                <div class="tools">
                  <el-row>
                    <el-col :span="12">
                      <el-button type="text" class="el_long" plain @click="modal=true">查看/编辑</el-button>
                    </el-col>
                    <el-col :span="12">
                      <el-button
                        type="text"
                        class="el_long el_btn_gray"
                        plain
                        @click="deleteMsg(item)"
                      >删除记录</el-button>
                    </el-col>
                  </el-row>
                </div>
              </div>
            </el-col>
          </template>
        </el-row>
        <h2 v-else>系统未检索到相关结果…</h2>
      </div>
    </div>
    <div class="text-right el_t_20 page_box" v-if="list.length > 0">
      <el-pagination
        :current-page="1"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="list.length"
      ></el-pagination>
    </div>
    <el-dialog title="预约信息" :visible.sync="modal" width="70%" :before-close="closed">
      <el-table :data="list" stripe height="360">
        <el-table-column label="姓名" prop="name" width="100"></el-table-column>
        <el-table-column label="电话" prop="phone" width="120"></el-table-column>
        <el-table-column label="预约医生" prop="name" width="120"></el-table-column>
        <el-table-column label="备注" prop="remark" min-width="150">
          <template slot-scope="data">
            <p class="hidden" v-html="data.row.remark"></p>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "second",
  data() {
    return {
      modal: false,
      listType: 1,
      height: 0,
      searchMore: false,
      search: {
        name: ""
      },
      users: [
        {
          key: 0,
          label: "请选择责任人"
        },
        {
          key: 1,
          label: "不限"
        },
        {
          key: 2,
          label: "王小红"
        },
        {
          key: 3,
          label: "某某"
        }
      ],
      list: [
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        }
      ]
    };
  },
  methods: {
    closed() {
      this.modal = false;
    },
    addInfo() {
      this.$router.push({ name: "caseBookEdit" });
    },
    listTypeChange(val) {
      this.listType = val;
    },
    deleteMsg(data) {
      this.$confirm("确定删除该条记录？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "点错了",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  }
};
</script>

<style scoped>
.case {
  border-bottom: 1px solid rgb(194, 228, 198);
  overflow: hidden;
  position: relative;
}
.case .tag {
  display: inline-block;
  width: 50px;
  border: 1px solid #006835;
  border-radius: 15px;
  padding: 2px 5px;
  font-size: 12px;
  color: #006835;
  position: absolute;
  right: 10px;
  top: 10px;
  text-align: center;
}

.tag.warning {
  color: #e6a23c;
  border-color: #e6a23c;
}

.tag.disabled {
  color: #c0c4cc;
  border-color: #c0c4cc;
}

.item {
  width: 100%;
  border: 1px solid rgb(194, 228, 198);
  background: #f3fdf8;
}

.item .photo {
  width: 50px;
  height: 50px;
  float: left;
  margin: 20px;
}

.photo img {
  width: 100%;
}

.item .text {
  width: calc(100% - 90px);
  float: left;
  padding-top: 10px;
}

.text p {
  font-size: 12px;
  color: rgb(102, 102, 102);
  line-height: 1;
}

.text p span {
  font-size: 16px;
  font-weight: bold;
  color: #333333;
  margin-right: 20px;
}

em {
  display: inline-block;
  font-style: normal;
  width: calc(100% - 50px);
  overflow: hidden;
  -ms-text-overflow: ellipsis;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools {
  width: 100%;
  overflow: hidden;
}

.tools button {
  background: #ffffff !important;
  border: none !important;
}

.tools .el-row .el-col:first-child {
  border-right: 1px solid rgb(194, 228, 198);
}

.box > .el-row > .el-col {
  margin-bottom: 20px;
}

.content {
  margin-top: 10px;
  height: calc(100vh - 270px);
  background: #ffffff;
  position: relative;
  padding: 20px;
}

.content.active {
  height: calc(100vh - 347px);
}

.box {
  max-height: calc(100% - 50px);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.content.active .box {
  max-height: calc(100% - 40px);
}

.box h2 {
  font-size: 14px;
  font-weight: normal;
}

.page_box {
  right: 20px;
  bottom: 20px;
}

.rotate {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  transform: rotate(90deg);
}

.rotate.active {
  -webkit-transform: rotate(-90deg);
  -moz-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);
  transform: rotate(-90deg);
}
</style>
